﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace NewRen.Models.ViewModel
{
    public class vPlate
    {
        /// <summary>
        /// ID
        /// </summary>
        public int ID { set; get; }

        /// <summary>
        ///  板块名
        /// </summary>
        public string Title { set; get; }

        /// <summary>
        /// 图片
        /// </summary>
        public byte[] Picture { set; get; }

        /// <summary>
        /// 描述
        /// </summary>
        public string Description { set; get; }


        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime Time { set; get; }



        /// <summary>
        /// 浏览
        /// </summary>
        public int Browses { get; set; }

        /// <summary>
        /// 关注量
        /// </summary>
        public int Collect { get; set; }

        public vPlate() { }

        public vPlate(Plate model)
        {
            DB db = new DB();
            this.ID = model.ID;
            this.Title = model.Title;
            this.Time = model.Time;
            this.Picture = model.Picture;
            this.Browses = model.Browses;
            this.Description = model.Description;
            this.Collect = db.Collects.Where(x => x.TID == model.ID).Where(x => x.CollectTypeAsInt==2).Count();
        }
    }
}